﻿namespace Nello.Data
{
    using System;
    using System.Data;

    public class LinkerUtil
    {
        public static DataRow ExecuteDataRow(string s)
        {
            return ExecuteDataRow("", s);
        }

        public static DataRow ExecuteDataRow(string cnnStr, string s)
        {
            Linker linker = new Linker(cnnStr);
            linker.Open();
            DataRow ret = linker.ExecuteDataRow(s);
            linker.Close();
            return ret;
        }

        public static DataSet ExecuteDataSet(string s)
        {
            return ExecuteDataSet("", s);
        }

        public static DataSet ExecuteDataSet(string cnnStr, string s)
        {
            Linker linker = new Linker(cnnStr);
            linker.Open();
            DataSet ds = linker.ExecuteDataSet(s);
            linker.Close();
            return ds;
        }

        public static DataTable ExecuteDataTable(string s)
        {
            return ExecuteDataTable("", s);
        }

        public static DataTable ExecuteDataTable(string cnnStr, string s)
        {
            Linker linker = new Linker(cnnStr);
            linker.Open();
            DataTable dt = linker.ExecuteDataTable(s);
            linker.Close();
            return dt;
        }

        public static int ExecuteNonQuery(string s)
        {
            return ExecuteNonQuery("", s);
        }

        public static int ExecuteNonQuery(string cnnStr, string s)
        {
            Linker linker = new Linker(cnnStr);
            linker.Open();
            int ret = linker.ExecuteNonQuery(s);
            linker.Commit();
            linker.Close();
            return ret;
        }

        public static object ExecuteScalar(string s)
        {
            return ExecuteScalar("", s);
        }

        public static object ExecuteScalar(string cnnStr, string s)
        {
            Linker linker = new Linker(cnnStr);
            linker.Open();
            object ret = linker.ExecuteScalar(s);
            linker.Close();
            return ret;
        }
    }
}

